package java111_2;

import java.util.Arrays;
import java.util.Scanner;

public class Day32 {
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        StringBuilder sb = new StringBuilder(t + "");
        sb.reverse();
        String tmp = t + "";
        tmp = tmp + sb.substring(1);
        long res = Long.parseLong(tmp);

        System.out.println(isS(res) ? "prime" : "noprime");
    }
    public static boolean isS(long x){
        for (long i = 2; i <= Math.sqrt(x); i++) {
            if(x % i == 0){
                return false;
            }
        }
        return true;
    }


    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), res = 0;
        int[][] arr = new int[n][2];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < 2; j++){
                arr[i][j] = in.nextInt();
            }
        }
        Arrays.sort(arr, (x1, x2) -> {
            if(x1[0] == x2[0]){
                return x2[1] - x1[1];
            } else {
                return x1[0] - x2[0];
            }
        });
        int tmp = arr[0][1];
        for(int i = 1; i < n; i++){
            if(arr[i][0] == arr[i-1][0] && arr[i][1] < tmp){
                tmp = arr[i][1];
            } else {
                break;
            }
        }
        for(int i = 1; i < n; i++){
            if(tmp <= arr[i][0]){
                res++;
                tmp = arr[i][1];
            }
        }
        System.out.println(res+1);

    }
}
